#include "AugAssign.h"
#include "IVisitor.h"

AugAssign::AugAssign(const exprTypePtr& target, int op, const exprTypePtr& value, int nodeId):
    stmtType(nodeId),
    _target(target),
    _op(op),
    _value(value)
{
}
    
AugAssign::~AugAssign()
{
    
}
    
QString AugAssign::type() const
{
    return "AugAssign";
}
    

exprTypePtr AugAssign::target()
{
    return _target;
}

void AugAssign::setTarget(const exprTypePtr& target)
{
    _target = target;
}

int AugAssign::op()
{
    return _op;
}

void AugAssign::setOp(int op)
{
    _op = op;
}

exprTypePtr AugAssign::value()
{
    return _value;
}

void AugAssign::setValue(const exprTypePtr& value)
{
    _value = value;
}

    
QString AugAssign::toString() const
{
    return QString("AugAssign[target=%1, op=%2, value=%3]").
                arg(_target ? _target->toString():"").
                arg(_op).
                arg(_value ? _value->toString():"");
}
    
void AugAssign::accept(IVisitor* visitor, const SimpleNodePtr& node)
{
    visitor->visitAugAssign(node.dynamicCast<AugAssign>());
}
    
void AugAssign::traverse(IVisitor* visitor)
{
    if (_target != NULL)
        _target->accept(visitor, _target);
    if (_value != NULL)
        _value->accept(visitor, _value);
}